#include "KPanel.h"

KPanel::KPanel():
KControl(3)
{
	m_Image = NULL;
	m_bTransparent = false;
}

KPanel::~KPanel()
{
	if(m_Image != NULL)
		delete m_Image;
}

void KPanel::SetImage(const WCHAR * szPath, COLORREF bkColor)
{
	if(szPath == NULL || lstrcmp(szPath, TEXT("")) == 0)
		return;

	if(m_Image == NULL)
		m_Image = new KImage();

	if(bkColor != -1)
		m_bTransparent = true;

	m_Image->Load(szPath);
}

bool KPanel::Paint( KMessage & rMsg )
{
	if(m_Image != NULL)
	{
		HDC hdc = (HDC)rMsg.lParam;

		if(m_bTransparent)
			m_Image->TransparentBlt(hdc, m_Bounds.x, m_Bounds.y, m_Bounds.w, m_Bounds.h);
		else
			m_Image->StretchBlt(hdc, m_Bounds.x, m_Bounds.y, m_Bounds.w, m_Bounds.h);
	}
	
	return true;
}